package com.app.manage.moudles.system.service.impl;

import cn.dev33.satoken.stp.StpUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.app.manage.moudles.system.dao.TUserDao;
import com.app.manage.moudles.system.entity.TUser;
import com.app.manage.moudles.system.service.TUserService;
import org.springframework.stereotype.Service;

/**
 * (TUser)表服务实现类
 *
 * @author makejava
 * @since 2025-05-19 11:20:09
 */
@Service("tUserService")
public class TUserServiceImpl extends ServiceImpl<TUserDao, TUser> implements TUserService {

    @Override
    public TUser loginUser(String userName, String pwd) throws Exception {
        TUser tUser = getOne(new LambdaQueryWrapper<TUser>().eq(TUser::getLoginName,userName).last("limit 1"));
        if(tUser == null){
            throw new RuntimeException("用户账号不存在!");
        }
        if(!tUser.getLoginPwd().equals(pwd)){
            throw new RuntimeException("账号密码错误");
        }

        return tUser;
    }
}

